package com.xtkj.superclub_user.conf;

import com.xtkj.superclub_user.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lizheqi
 * @create 2020-01-03-10:14
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {
    @Autowired
    private TokenInterceptor tokenInterceptor;
    //此方法是用来注册拦截器，自己写好的拦截器需要通过添加注册才能生效
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPattern("/**")表示拦截所有的请求
        //excludePathPatterns("/login","/register")表示除登录与注册之外
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**");
    }
    //此方法是用来配置静态资源的
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

    }
}
